(0) Obligation:

The Runtime Complexity (innermost) of the given CpxTRS could be proven to be BOUNDS(1, n^1).


The TRS R consists of the following rules:

minus(x, 0) → x
minus(s(x), s(y)) → minus(x, y)
quot(0, s(y)) → 0
quot(s(x), s(y)) → s(quot(minus(x, y), s(y)))

Rewrite Strategy: INNERMOST

(1) TrsToWeightedTrsProof (BOTH BOUNDS(ID, ID) transformation)

Transformed TRS to weighted TRS

(2) Obligation:

The Runtime Complexity (innermost) of the given CpxWeightedTrs could be proven to be BOUNDS(1, n^1).


The TRS R consists of the following rules:

minus(x, 0) → x [1]
minus(s(x), s(y)) → minus(x, y) [1]
quot(0, s(y)) → 0 [1]
quot(s(x), s(y)) → s(quot(minus(x, y), s(y))) [1]

Rewrite Strategy: INNERMOST

(3) TypeInferenceProof (BOTH BOUNDS(ID, ID) transformation)

Infered types.

(4) Obligation:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

minus(x, 0) → x [1]
minus(s(x), s(y)) → minus(x, y) [1]
quot(0, s(y)) → 0 [1]
quot(s(x), s(y)) → s(quot(minus(x, y), s(y))) [1]

The TRS has the following type information:
minus :: 0:s → 0:s → 0:s
0 :: 0:s
s :: 0:s → 0:s
quot :: 0:s → 0:s → 0:s

Rewrite Strategy: INNERMOST

(5) CompletionProof (UPPER BOUND(ID) transformation)

The TRS is a completely defined constructor system, as every type has a constant constructor and the following rules were added:

minus(v0, v1) → null_minus [0]
quot(v0, v1) → null_quot [0]

And the following fresh constants:

null_minus, null_quot

(6) Obligation:

Runtime Complexity Weighted TRS where all functions are completely defined. The underlying TRS is:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

minus(x, 0) → x [1]
minus(s(x), s(y)) → minus(x, y) [1]
quot(0, s(y)) → 0 [1]
quot(s(x), s(y)) → s(quot(minus(x, y), s(y))) [1]
minus(v0, v1) → null_minus [0]
quot(v0, v1) → null_quot [0]

The TRS has the following type information:
minus :: 0:s:null_minus:null_quot → 0:s:null_minus:null_quot → 0:s:null_minus:null_quot
0 :: 0:s:null_minus:null_quot
s :: 0:s:null_minus:null_quot → 0:s:null_minus:null_quot
quot :: 0:s:null_minus:null_quot → 0:s:null_minus:null_quot → 0:s:null_minus:null_quot
null_minus :: 0:s:null_minus:null_quot
null_quot :: 0:s:null_minus:null_quot

Rewrite Strategy: INNERMOST

(7) CpxTypedWeightedTrsToRntsProof (UPPER BOUND(ID) transformation)

Transformed the TRS into an over-approximating RNTS by (improved) Size Abstraction.
The constant constructors are abstracted as follows:

0 => 0
null_minus => 0
null_quot => 0

(8) Obligation:

Complexity RNTS consisting of the following rules:

minus(z, z') -{ 1 }→ x :|: x >= 0, z = x, z' = 0
minus(z, z') -{ 1 }→ minus(x, y) :|: z' = 1 + y, x >= 0, y >= 0, z = 1 + x
minus(z, z') -{ 0 }→ 0 :|: v0 >= 0, v1 >= 0, z = v0, z' = v1
quot(z, z') -{ 1 }→ 0 :|: z' = 1 + y, y >= 0, z = 0
quot(z, z') -{ 0 }→ 0 :|: v0 >= 0, v1 >= 0, z = v0, z' = v1
quot(z, z') -{ 1 }→ 1 + quot(minus(x, y), 1 + y) :|: z' = 1 + y, x >= 0, y >= 0, z = 1 + x

Only complete derivations are relevant for the runtime complexity.

(9) CompleteCoflocoProof (EQUIVALENT transformation)

Transformed the RNTS (where only complete derivations are relevant) into cost relations for CoFloCo:

eq(start(V, V1),0,[minus(V, V1, Out)],[V >= 0,V1 >= 0]).
eq(start(V, V1),0,[quot(V, V1, Out)],[V >= 0,V1 >= 0]).
eq(minus(V, V1, Out),1,[],[Out = V2,V2 >= 0,V = V2,V1 = 0]).
eq(minus(V, V1, Out),1,[minus(V3, V4, Ret)],[Out = Ret,V1 = 1 + V4,V3 >= 0,V4 >= 0,V = 1 + V3]).
eq(quot(V, V1, Out),1,[],[Out = 0,V1 = 1 + V5,V5 >= 0,V = 0]).
eq(quot(V, V1, Out),1,[minus(V6, V7, Ret10),quot(Ret10, 1 + V7, Ret1)],[Out = 1 + Ret1,V1 = 1 + V7,V6 >= 0,V7 >= 0,V = 1 + V6]).
eq(minus(V, V1, Out),0,[],[Out = 0,V8 >= 0,V9 >= 0,V = V8,V1 = V9]).
eq(quot(V, V1, Out),0,[],[Out = 0,V10 >= 0,V11 >= 0,V = V10,V1 = V11]).
input_output_vars(minus(V,V1,Out),[V,V1],[Out]).
input_output_vars(quot(V,V1,Out),[V,V1],[Out]).

CoFloCo proof output:
Preprocessing Cost Relations
=====================================

#### Computed strongly connected components
0. recursive : [minus/3]
1. recursive : [quot/3]
2. non_recursive : [start/2]

#### Obtained direct recursion through partial evaluation
0. SCC is partially evaluated into minus/3
1. SCC is partially evaluated into quot/3
2. SCC is partially evaluated into start/2

Control-Flow Refinement of Cost Relations
=====================================

### Specialization of cost equations minus/3
* CE 6 is refined into CE [10]
* CE 4 is refined into CE [11]
* CE 5 is refined into CE [12]


### Cost equations --> "Loop" of minus/3
* CEs [12] --> Loop 7
* CEs [10] --> Loop 8
* CEs [11] --> Loop 9

### Ranking functions of CR minus(V,V1,Out)
* RF of phase [7]: [V,V1]

#### Partial ranking functions of CR minus(V,V1,Out)
* Partial RF of phase [7]:
- RF of loop [7:1]:
V
V1


### Specialization of cost equations quot/3
* CE 7 is refined into CE [13]
* CE 9 is refined into CE [14]
* CE 8 is refined into CE [15,16,17]


### Cost equations --> "Loop" of quot/3
* CEs [17] --> Loop 10
* CEs [16] --> Loop 11
* CEs [15] --> Loop 12
* CEs [13,14] --> Loop 13

### Ranking functions of CR quot(V,V1,Out)
* RF of phase [10]: [V-1,V-V1+1]
* RF of phase [12]: [V]

#### Partial ranking functions of CR quot(V,V1,Out)
* Partial RF of phase [10]:
- RF of loop [10:1]:
V-1
V-V1+1
* Partial RF of phase [12]:
- RF of loop [12:1]:
V


### Specialization of cost equations start/2
* CE 2 is refined into CE [18,19,20]
* CE 3 is refined into CE [21,22,23,24,25]


### Cost equations --> "Loop" of start/2
* CEs [21] --> Loop 14
* CEs [18,19,20,22,23,24,25] --> Loop 15

### Ranking functions of CR start(V,V1)

#### Partial ranking functions of CR start(V,V1)


Computing Bounds
=====================================

#### Cost of chains of minus(V,V1,Out):
* Chain [[7],9]: 1*it(7)+1
Such that:it(7) =< V1

with precondition: [V=Out+V1,V1>=1,V>=V1]

* Chain [[7],8]: 1*it(7)+0
Such that:it(7) =< V1

with precondition: [Out=0,V>=1,V1>=1]

* Chain [9]: 1
with precondition: [V1=0,V=Out,V>=0]

* Chain [8]: 0
with precondition: [Out=0,V>=0,V1>=0]


#### Cost of chains of quot(V,V1,Out):
* Chain [[12],13]: 2*it(12)+1
Such that:it(12) =< Out

with precondition: [V1=1,Out>=1,V>=Out]

* Chain [[12],11,13]: 2*it(12)+1*s(2)+2
Such that:s(2) =< 1
it(12) =< Out

with precondition: [V1=1,Out>=2,V>=Out]

* Chain [[10],13]: 2*it(10)+1*s(5)+1
Such that:it(10) =< V-V1+1
aux(3) =< V
it(10) =< aux(3)
s(5) =< aux(3)

with precondition: [V1>=2,Out>=1,V+2>=2*Out+V1]

* Chain [[10],11,13]: 2*it(10)+1*s(2)+1*s(5)+2
Such that:it(10) =< V-V1+1
s(2) =< V1
aux(4) =< V
it(10) =< aux(4)
s(5) =< aux(4)

with precondition: [V1>=2,Out>=2,V+3>=2*Out+V1]

* Chain [13]: 1
with precondition: [Out=0,V>=0,V1>=0]

* Chain [11,13]: 1*s(2)+2
Such that:s(2) =< V1

with precondition: [Out=1,V>=1,V1>=1]


#### Cost of chains of start(V,V1):
* Chain [15]: 4*s(9)+4*s(12)+2*s(14)+2
Such that:aux(6) =< V
aux(7) =< V-V1+1
aux(8) =< V1
s(12) =< aux(7)
s(9) =< aux(8)
s(12) =< aux(6)
s(14) =< aux(6)

with precondition: [V>=0,V1>=0]

* Chain [14]: 1*s(19)+4*s(21)+2
Such that:s(19) =< 1
s(20) =< V
s(21) =< s(20)

with precondition: [V1=1,V>=1]


Closed-form bounds of start(V,V1):
-------------------------------------
* Chain [15] with precondition: [V>=0,V1>=0]
- Upper bound: 2*V+4*V1+2+nat(V-V1+1)*4
- Complexity: n
* Chain [14] with precondition: [V1=1,V>=1]
- Upper bound: 4*V+3
- Complexity: n

### Maximum cost of start(V,V1): 2*V+2+max([2*V+1,nat(V-V1+1)*4+4*V1])
Asymptotic class: n
* Total analysis performed in 190 ms.

(10) BOUNDS(1, n^1)